<?php

define('KC_INDEX',True);

require_once '../global.php';

/**

	创建内容页

	@param string $listid: 列表
	@param int    $kid   : 要生成的id
	@param int    $pid   : 第?页
	@param int    $is    : 生成或是返回值？1返回值
	@return string

*/
function king_def(){
	global $king;
	$king->load('portal');

	$listid=kc_get('listid',2,1);
	$time=kc_get('time',2);
	if(empty($time)) $time='900';
	$cachepath="gxzt/".$listid;
	//$cachepath2="gx/".$listid.'home';
	

	if(!$block=$king->cache->get($cachepath,time()-$time)){
		$data=$king->db->getRows_one("select kid,ktitle,listid,kcontent from %s__zhuanti where nshow='0' and listid=".$listid." order by kid asc");
		if(empty($data)){
			$data['ktitle']='已经更新完毕111';
		}else{
			if(!empty($data['kid'])){

				$kconter=kc_grab($data['kcontent']);
				if($oneimage=preg_match('/(<img([^>]*))( src=)(["\'])(.*?)\4(([^>]*)\/?>)/is',$kconter,$oneimage_array)){
					$smartimg=$oneimage_array[5];	
					
					$smartimg=str_replace('/browse/','',$smartimg);			
				}
				
				$king->db->update('%s__zhuanti',array('nshow'=>'1','nlastdate'=>time(),'ndate'=>time(),'kcontent'=>$kconter,'kimage'=>$smartimg),'kid='.$data['kid']);
				//$king->portal->createPage($data['listid'],$data['kid'],'1');
				$king->cache->put($cachepath,'最新更新：'.$data['ktitle']);
			}
		}
	}





	echo '<!--'.$block.$blockto.'-->';

	

}



?>